/**
 * Copyright (C) 2007 The AsyncMail Group <asyncmail@googlegroups.com>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *         http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.googlecode.asyncmail.smtpserver.mock.mina;

import java.util.ArrayList;
import java.util.List;

import org.apache.mina.common.IdleStatus;
import org.apache.mina.common.IoSession;
import org.apache.mina.common.IoFilter.NextFilter;
import org.apache.mina.common.IoFilter.WriteRequest;

public class MockNextFilter implements NextFilter {

    private boolean exceptionCaughtCalled = false;

    private boolean filterCloseCalled = false;

    private boolean filterWriteCalled = false;

    private boolean messageReceivedCalled = false;

    private boolean messageSentCalled = false;

    private boolean sessionClosedCalled = false;

    private boolean sessionCreatedCalled = false;

    private boolean sessionIdleCalled = false;

    private boolean sessionOpenedCalled = false;

    private List<WriteRequest> writtenRequests = new ArrayList<WriteRequest>();

    public void exceptionCaught(IoSession arg0, Throwable arg1) {
        this.exceptionCaughtCalled = true;
    }

    public void filterClose(IoSession arg0) {
        filterCloseCalled = true;
    }

    public void filterWrite(IoSession arg0, WriteRequest arg1) {
        filterWriteCalled = true;
        writtenRequests.add(arg1);
    }

    public void messageReceived(IoSession arg0, Object arg1) {
        messageReceivedCalled = true;
    }

    public void messageSent(IoSession arg0, Object arg1) {
        messageSentCalled = true;
    }

    public void sessionClosed(IoSession arg0) {
        sessionClosedCalled = true;
    }

    public void sessionCreated(IoSession arg0) {
        sessionCreatedCalled = true;
    }

    public void sessionIdle(IoSession arg0, IdleStatus arg1) {
        sessionIdleCalled = true;
    }

    public void sessionOpened(IoSession arg0) {
        sessionOpenedCalled = true;
    }

    public boolean filtercloseCalled() {
        return filterCloseCalled;
    }

    public boolean exceptionCaughtCalled() {
        return exceptionCaughtCalled;
    }

    public boolean filterWriteCalled() {
        return filterWriteCalled;
    }

    public boolean messageReceivedCalled() {
        return messageReceivedCalled;
    }

    public boolean messageSentCalled() {
        return messageSentCalled;
    }

    public boolean sessionClosedCalled() {
        return sessionClosedCalled;
    }

    public boolean sessionCreatedCalled() {
        return sessionCreatedCalled;
    }

    public boolean sessionIdleCalled() {
        return sessionIdleCalled;
    }

    public boolean sessionOpenedCalled() {
        return sessionOpenedCalled;
    }

    public List<WriteRequest> getWrittenRequests() {
        return writtenRequests;
    }

}
